#ifndef __SINGLETON_H__
#define __SINGLETON_H__
#include <stdio.h>

template <typename T> 
class CSingleton
{
public:
    static T* Instance()
    {
        if (m_instance == NULL) m_instance = new T;

        return m_instance;
    };

    static void DestroyInstance()
    {
        delete m_instance;
        m_instance = NULL;
    };

protected:
    CSingleton()
    {
    };

    virtual ~CSingleton()
    {
    };

private:
    CSingleton(const CSingleton& source)
    {
    };

    static T* m_instance;
};

//! static class member initialisation.
template <typename T> T* CSingleton<T>::m_instance = NULL;


#endif // ! defined __SINGLETON_H__
